<?php
/**
 * Created by PhpStorm.
 * User: Sunmer
 * Date: 2019/5/31 0031
 * Time: 17:22
 * Email:Sunmer@foxmail.com
 */
namespace app\api\controller;
use think\Db;

class Login extends BaseController{
    /**
     * 登录
     * @return \think\Response|\think\response\Json|\think\response\Jsonp|\think\response\Redirect|\think\response\View|\think\response\Xml
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function login(){
        //接受参数
        $result = request()->param();
        if (empty($result['mobile'])||empty($result['password'])){
            return $this->ajax_return('null','参数不完整','201');
        }
        //验证参数啊
        $argc = DB::table('tp_user')->where('member_mobile',$result['mobile'])->find();
        if ($argc){
            //验证密码是否匹配
            if (parent::password($result['password']) == $argc['member_password']){
                return $this->ajax_return($argc,'登录成功','200');
            }else{
                return $this->ajax_return('null','密码不正确','201');
            }
        }
    }
}